package com.it.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class CodeUtils {
    //获取编码格式--通过数据总数给后三位判断
    public static String getCodeByCountDP(int count) {//委外
        String one = "DP-";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
        simpleDateFormat.applyPattern("yyyy-MM-dd");//CH-2023-12-22-001
        String code = null;
        if (count > 0 && count < 10) {
            code = one + simpleDateFormat.format(new Date()) + "-00" + count;
        }
        if (count >= 10 && count < 99) {
            code = one + simpleDateFormat.format(new Date()) + "-0" + count;
        }
        if (count >= 99 && count < 1000) {
            code = one + simpleDateFormat.format(new Date()) + "-" + count;
        }
        return code;
    }

    public static String getCodeByCountCF(int count) {//产废
        String one = "CH-";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
        simpleDateFormat.applyPattern("yyyy-MM-dd");//CH-2023-12-22-001
        String code = null;
        if (count > 0 && count < 10) {
            code = one + simpleDateFormat.format(new Date()) + "-00" + count;
        }
        if (count >= 10 && count < 99) {
            code = one + simpleDateFormat.format(new Date()) + "-0" + count;
        }
        if (count >= 99 && count < 1000) {
            code = one + simpleDateFormat.format(new Date()) + "-" + count;
        }
        return code;
    }

    public static String getCodeByCountIT(int count) {//入库
        String one = "IT-";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
        simpleDateFormat.applyPattern("yyyy-MM-dd");//CH-2023-12-22-001
        String code = null;
        if (count > 0 && count < 10) {
            code = one + simpleDateFormat.format(new Date()) + "-00" + count;
        }
        if (count >= 10 && count < 99) {
            code = one + simpleDateFormat.format(new Date()) + "-0" + count;
        }
        if (count >= 99 && count < 1000) {
            code = one + simpleDateFormat.format(new Date()) + "-" + count;
        }
        return code;
    }

    public static String getCodeByCountOT(int count) {//出库
        String one = "OT-";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
        simpleDateFormat.applyPattern("yyyy-MM-dd");//CH-2023-12-22-001
        String code = null;
        if (count > 0 && count < 10) {
            code = one + simpleDateFormat.format(new Date()) + "-00" + count;
        }
        if (count >= 10 && count < 99) {
            code = one + simpleDateFormat.format(new Date()) + "-0" + count;
        }
        if (count >= 99 && count < 1000) {
            code = one + simpleDateFormat.format(new Date()) + "-" + count;
        }
        return code;
    }

    public static String getCodeByCountDT(int count) {//自行利用编码
        String one = "DT-";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
        simpleDateFormat.applyPattern("yyyy-MM-dd");//CH-2023-12-22-001
        String code = null;
        if (count > 0 && count < 10) {
            code = one + simpleDateFormat.format(new Date()) + "-00" + count;
        }
        if (count >= 10 && count < 99) {
            code = one + simpleDateFormat.format(new Date()) + "-0" + count;
        }
        if (count >= 99 && count < 1000) {
            code = one + simpleDateFormat.format(new Date()) + "-" + count;
        }
        return code;
    }
    public static String getCodeByCountCT(int count) {//容器
        String one = "CT-";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
        simpleDateFormat.applyPattern("yyyy-MM-dd");//CH-2023-12-22-001
        String code = null;
        if (count > 0 && count < 10) {
            code = one + simpleDateFormat.format(new Date()) + "-00" + count;
        }
        if (count >= 10 && count < 99) {
            code = one + simpleDateFormat.format(new Date()) + "-0" + count;
        }
        if (count >= 99 && count < 1000) {
            code = one + simpleDateFormat.format(new Date()) + "-" + count;
        }
        return code;
    }



}